package com.sec.bnjey.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sec.bnjey.R;
import com.sec.bnjey.activity.NewMileageActivity.DriveHistoryEntity;
import com.sec.bnjey.utils.RbLog;

public class MileageHistoryAdapter extends BaseAdapter {

	final String TAG = "MileageHistoryAdapter";

	public Context mContext;
	private ArrayList<DriveHistoryEntity> mDriveHistoryArrayList;
	private LayoutInflater mLayoutInflater;
	int resource;

	public MileageHistoryAdapter(Context context, int resource,
			ArrayList<DriveHistoryEntity> arrayList) {
		mContext = context;
		this.mDriveHistoryArrayList = arrayList;
		this.mLayoutInflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		this.resource = resource;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mDriveHistoryArrayList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {

		Holder holder = new Holder();

		if (convertView == null) {

			convertView = mLayoutInflater.inflate(resource, null);

			holder.tv_content = (TextView) convertView
					.findViewById(R.id.tv_content);
			convertView.setTag(holder);

		} else {
			holder = (Holder) convertView.getTag();
		}

		RbLog.d(TAG, "getView pos " + position);
		// msg
		String setSingleLine = mDriveHistoryArrayList.get(position).title;
		holder.tv_content.setText(setSingleLine);

		return convertView;
	}

	private class Holder {
		TextView tv_content;
	}

}
